package com.dingreading.cloud.soms.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.soms.service.CmOrderCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/front/cmOrderCount")
@Api(tags = "门店-会员订单统计管理")
public class FrontCmOrderCountController {

    @Resource
    private CmOrderCountService cmOrderCountService;


    @ApiOperation(value = "分页列表")
    @PostMapping(value = "/pageList")
    public R<Object> pageList(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "开始时间 yyyy-MM-dd") @RequestParam(value = "beginDate") String beginDate,
            @ApiParam(value = "结束时间 yyyy-MM-dd") @RequestParam(value = "endDate") String endDate
    ) throws Exception {
        return cmOrderCountService.cmOrderCount(corpUid, storeUid, staffUid, beginDate, endDate);
    }

    @ApiOperation(value = "导出")
    @PostMapping(value = "/export", produces = "application/vnd.ms-excel;charset=UTF-8")
    public void export(
            HttpServletResponse response,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "开始时间 yyyy-MM-dd") @RequestParam(value = "beginDate") String beginDate,
            @ApiParam(value = "结束时间 yyyy-MM-dd") @RequestParam(value = "endDate") String endDate
    ) throws Exception {
        cmOrderCountService.export(response, corpUid, storeUid, staffUid, beginDate, endDate);
    }

}
